GtkCellAreaBoxContext *context);
static GSList *get_allocated_cells (GtkCellAreaBox *box,
GtkCellAreaBoxContext *context,
- GtkWidget *widget);
+ GtkWidget *widget,
+ gint orientation_size);
struct _GtkCellAreaBoxPrivate
static GSList *
get_allocated_cells (GtkCellAreaBox *box,
GtkCellAreaBoxContext *context,
- GtkWidget *widget)
+ GtkWidget *widget,
+ gint orientation_size)
{
- const GtkCellAreaBoxAllocation *group_allocs;
- GtkCellArea *area = GTK_CELL_AREA (box);
- GtkCellAreaBoxPrivate *priv = box->priv;
- GList *cell_list;
- GSList *allocated_cells = NULL;
- gint i, j, n_allocs;
+ GtkCellAreaBoxAllocation *group_allocs;
+ GtkCellArea *area = GTK_CELL_AREA (box);
+ GtkCellAreaBoxPrivate *priv = box->priv;
+ GList *cell_list;
+ GSList *allocated_cells = NULL;
+ gint i, j, n_allocs;
+ gboolean free_allocs = FALSE;
group_allocs = gtk_cell_area_box_context_get_orientation_allocs (context, &n_allocs);
if (!group_allocs)
{
- g_warning ("Trying to operate on an unallocated GtkCellAreaContext, "
- "GtkCellAreaBox requires that the context be allocated at least "
- "in the orientation of the box");
- return NULL;
+ group_allocs = gtk_cell_area_box_context_allocate (context, orientation_size, &n_allocs);
+ free_allocs = TRUE;
}
for (i = 0; i < n_allocs; i++)
}
}
+ if (free_allocs)
+ g_free (group_allocs);
+
/* Note it might not be important to reverse the list here at all,
* we have the correct positions, no need to allocate from left to right */
return g_slist_reverse (allocated_cells);
/* Get a list of cells with allocation sizes decided regardless
* of alignments and pack order etc. */
- allocated_cells = get_allocated_cells (box, box_context, widget);
+ allocated_cells = get_allocated_cells (box, box_context, widget,
+ priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
+ cell_area->width : cell_area->height);
for (l = allocated_cells; l; l = l->next)
{
/* Get a list of cells with allocation sizes decided regardless
* of alignments and pack order etc. */
- allocated_cells = get_allocated_cells (box, box_context, widget);
+ allocated_cells = get_allocated_cells (box, box_context, widget,
+ priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
+ cell_area->width : cell_area->height);
for (l = allocated_cells; l; l = l->next)
{
/* Get a list of cells with allocation sizes decided regardless
* of alignments and pack order etc. */
- allocated_cells = get_allocated_cells (box, box_context, widget);
+ allocated_cells = get_allocated_cells (box, box_context, widget,
+ priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
+ cell_area->width : cell_area->height);
for (l = allocated_cells; l; l = l->next)
{
{
GtkCellAreaBoxContext *box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
GtkCellAreaBoxContextPrivate *priv = box_context->priv;
- GtkCellArea *area;
- GtkOrientation orientation;
+ GtkCellArea *area;
+ GtkOrientation orientation;
area = gtk_cell_area_context_get_area (context);
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (area));
GTK_CELL_AREA_CONTEXT_CLASS (gtk_cell_area_box_context_parent_class)->allocate_height (context, height);
}
+
/*************************************************************
* API *
*************************************************************/
return gtk_cell_area_box_context_get_requests (box_context, GTK_ORIENTATION_VERTICAL, n_heights);
}
-G_CONST_RETURN GtkCellAreaBoxAllocation *
+GtkCellAreaBoxAllocation *
gtk_cell_area_box_context_get_orientation_allocs (GtkCellAreaBoxContext *context,
gint *n_allocs)
{
*n_allocs = priv->n_orientation_allocs;
return priv->orientation_allocs;
+
+}
+
+GtkCellAreaBoxAllocation *
+gtk_cell_area_box_context_allocate (GtkCellAreaBoxContext *context,
+ gint orientation_size,
+ gint *n_allocs)
+{
+ GtkCellArea *area;
+ GtkOrientation orientation;
+ gint spacing;
+
+ area = gtk_cell_area_context_get_area (GTK_CELL_AREA_CONTEXT (context));
+ orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (area));
+ spacing = gtk_cell_area_box_get_spacing (GTK_CELL_AREA_BOX (area));
+
+ return allocate_for_orientation (context, orientation, spacing, orientation_size, n_allocs);
}